package com.tank.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.tank.bean.item.Comment;
import com.tank.bean.item.Item;
import com.tank.bean.item.Transpond;
import com.tank.service.ItemService;
import com.tank.vo.RsVo;

@Controller("itemAction")
@Scope("prototype")
public class ItemAction extends ActionSupport {

	Item item;
	Transpond transpond;
	Comment comment;
	
	@Autowired
	@Qualifier("itemService")
	ItemService service;
	
	RsVo rs;
	
	
	public Transpond getTranspond() {
		return transpond;
	}

	public void setTranspond(Transpond transpond) {
		this.transpond = transpond;
	}

	public Comment getComment() {
		return comment;
	}

	public void setComment(Comment comment) {
		this.comment = comment;
	}

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}

	public ItemService getService() {
		return service;
	}

	public void setService(ItemService service) {
		this.service = service;
	}

	public RsVo getRs() {
		return rs;
	}

	public void setRs(RsVo rs) {
		this.rs = rs;
	}

	public String publish() throws Exception {

		if(item != null) System.out.println("发布的内容为："+item.getContent());

		if (service.publish(item)) {
			
			return SUCCESS;
		}
		return ERROR;
	}
	
	public String favour() throws Exception {
		//rs=service.favour(item);		
		return SUCCESS;
	}
	
	public String transpond() throws Exception {
		rs=service.transpond(transpond);		
		return SUCCESS;
	}
	
	public String comment() throws Exception {
		rs=service.comment(comment);		
		return SUCCESS;
	}
	
	public String remove() throws Exception {
		rs=service.remove(item);		
		return SUCCESS;
	}
	
}
